﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Maman18
{
    class Program
    {
        static void Main(string[] args)
        {
            #region Const
            const int GET_BOX = 1;
            const int INSERT_BOX = 2;
            const int REMOVE_BOX = 3;
            const int CHECK_BOX = 4;
            const int EXIT = 5;
            #endregion
            
            BoxesWorkshop Boxes = new BoxesWorkshop();

            Console.WriteLine("Welcome! \nWhat would you like to do?");
            Console.WriteLine("Get a box - " + GET_BOX);
            Console.WriteLine("Insert a box - " + INSERT_BOX);
            Console.WriteLine("Remove a box - " + REMOVE_BOX);
            Console.WriteLine("Check if a box exists - " + CHECK_BOX);
            Console.WriteLine("Exit - " + EXIT);
            Console.WriteLine("Enter your choice: ");

            int Choise = int.Parse(Console.ReadLine());

            // While the user don't exit the program
            while (Choise != EXIT)
            {
                switch (Choise)
                {
                    case (GET_BOX):
                        {
                            Console.WriteLine("Enter the size of the side");
                            int side = int.Parse(Console.ReadLine());
                            Console.WriteLine("Enter the size of the height");
                            int height = int.Parse(Console.ReadLine());
                            Box OutBox = Boxes.GetBox(side, height);

                            if (OutBox != null)
                            {
                                Console.WriteLine("The box with side " + OutBox.Side + " and height " + OutBox.Height + " was returned.");
                            }
                            else
                            {
                                Console.WriteLine("No box was found.");
                            }
                            break;
                        }
                    case (INSERT_BOX):
                        {
                            Console.WriteLine("Enter the size of the side");
                            int side = int.Parse(Console.ReadLine());
                            Console.WriteLine("Enter the size of the height");
                            int height = int.Parse(Console.ReadLine());
                            Boxes.InsertBox(side, height);

                            break;
                        }
                    case (REMOVE_BOX):
                        {
                            Console.WriteLine("Enter the size of the side");
                            int side = int.Parse(Console.ReadLine());
                            Console.WriteLine("Enter the size of the height");
                            int height = int.Parse(Console.ReadLine());
                            try
                            {
                                Boxes.RemoveBox(side, height);
                                Console.WriteLine("The box was removed");
                            }
                            catch
                            {
                                Console.WriteLine("There was a problem removing that box");
                            }

                            break;
                        }

                    case (CHECK_BOX):
                        {
                            Console.WriteLine("Enter the size of the side");
                            int side = int.Parse(Console.ReadLine());
                            Console.WriteLine("Enter the size of the height");
                            int height = int.Parse(Console.ReadLine());

                            // Check if the box exists
                            bool bExists = Boxes.CheckBox(side, height);

                            if (bExists)
                            {
                                Console.WriteLine("The box exists.");
                            }
                            else
                            {
                                Console.WriteLine("The box doesn't exists.");
                            }

                            break;
                        }

                        
                }

                Console.WriteLine("What would you like to do?");
                Console.WriteLine("Get a box - " + GET_BOX);
                Console.WriteLine("Insert a box - " + INSERT_BOX);
                Console.WriteLine("Remove a box - " + REMOVE_BOX);
                Console.WriteLine("Check if a box exists - " + CHECK_BOX);
                Console.WriteLine("Exit - " + EXIT);
                Console.WriteLine("Enter your choice: ");

                Choise = int.Parse(Console.ReadLine());

            }
        }
    }
}
